package main

import (
	"fmt"
)

func main() {
	for i := 1; i <= 3; i++ {

		fmt.Printf("这是第%d句话\n", i)

	}
	var str string = "hello" //传统遍历字符串
	for i := 0; i < len(str); i++ {
		fmt.Printf("%c \n", str[i])
	}
	str = "world" //for-range遍历字符串
	for index, val := range str {
		fmt.Printf("index=%d, val=%c \n", index, val)
	}
	str = "hello!北京" //传统遍历按照字节遍历，一个汉字3个字节，所以遍历字符串含有中文，需要转换成[]rune切片
	str2 := []rune(str)
	for i := 0; i < len(str2); i++ {
		fmt.Printf("%c \n", str2[i])
	}
	for index, val := range str { //for-range遍历按照字符遍历，字符串有中文也可以
		fmt.Printf("index=%d, val=%c ", index, val)
		fmt.Printf("%c \n", val)
	}
	sum_9 := 0
	count_9 := 0
	for j := 1; j < 101; j++ {
		if j%9 == 0 {
			sum_9 += j
			count_9 += 1
		}
	}
	fmt.Println(count_9, sum_9) //练习一

	n := 60
	for i := 0; i <= n; i++ {
		fmt.Println(i, "+", n-i, "=", n) //练习二
	}

	k := 0
	m := 0
	for k < 2 && m < 2 { //多个条件
		fmt.Println(k, m)
		k++
		m++
	}

	for {
		if k > 3 && m > 3 { //实现
			break
		}
		fmt.Println("00", k, m)
		k++
		m += 2
	}
}
